package com.zzr.darkme.controller;

import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 页面控制器
 *
 * @author zzr
 */
@Slf4j
@Controller
public class PageController {

    @RequestMapping("/")
    public String goMain(HttpServletResponse response) {
        response.setContentType("text/html;charset=utf-8");
        return "main";
    }

    @RequestMapping("hello")
    public String sayHello() {
        return "hello";
    }

    @RequestMapping("index")
    public String main(HttpServletResponse response, Model model) {
        response.setContentType("text/html;charset=utf-8");
        model.addAttribute("subFrame", "hello");
        return "index";
    }

    @RequestMapping("goSource")
    public void goGit(HttpServletResponse response) throws IOException {
        response.sendRedirect("https://github.com/TreeLiked/darkme2");
    }

}